import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";

// https://vite.dev/config/
export default defineConfig({
  base:"./",
  plugins: [vue()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server:{
    port: 8080,
    host: "0.0.0.0",
  },
  css: {
    preprocessorOptions: {
      scss: {
        api:'modern-compiler',
        additionalData: `@use "@/assets/style/variables.scss";`,
      }
    }
  },
  build: {
    
    // 配置输出文件名模板，包含哈希值
    rollupOptions: {
      
      // 在输出文件名中包含哈希值
      output: {
        chunkFileNames: 'js/[name].[hash].js',
        entryFileNames: 'js/[name].[hash].js',
        assetFileNames: 'assets/[name].[hash][extname]',
      },
    },
    // 配置源映射，如果需要
    sourcemap: true,
  },
})
